

package proms.net.modelo.comando;

import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import proms.net.modelo.bean.Pericia;
import proms.net.modelo.dao.PericiaDAO;

public class CadastrarPericia implements InterfaceComando {

    private PericiaDAO periciaDAO;

    public CadastrarPericia(PericiaDAO periciaDAO) {
        this.periciaDAO = periciaDAO;
    }

    public String execute(HttpServletRequest request, HttpServletResponse response) {

        Pericia pericia = new Pericia();
        pericia.setCodPericia(1);
        pericia.setCodProcesso(Integer.valueOf(request.getParameter("codprocesso")));
        pericia.setData(request.getParameter("data_pericia"));
        pericia.setHora(request.getParameter("hora"));
        pericia.setPerito(request.getParameter("perito"));
        try {
            periciaDAO.salvarPericia(pericia);
            request.setAttribute("mensagemPer", "Pericia Gravada");
        } catch (SQLException ex) {
            request.setAttribute("mensagemPer", "Problemas com"+ex.getMessage());
            ex.printStackTrace();
        }

        return "cadastro_processo.jsp";
    }

}
